﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Web;

namespace V5_EShop._Class.Common {
    /// <summary>
    /// 站点相关
    /// </summary>
    public class SiteHelper {
        //模板
        public static string TemplateDir { get; set; } = System.Configuration.ConfigurationManager.AppSettings["TemplateDir"] ?? "Default";

        //修改模板
        public static void ChangeTemplateDir(string templateDir = "Default") {
            string assemblyConfigFile = Assembly.GetEntryAssembly().Location;
            string appDomainConfigFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");

            appSettings.Settings.Remove("TemplateDir");
            appSettings.Settings.Add("TemplateDir", templateDir);

            //保存配置文件
            config.Save();
        }
    }
}